# -*- coding: utf-8 -*-
"""
Created on Tue Feb 19 14:55:43 2013

@author: aponteeduarddo@gmail.com
Copyright Eduardo Aponte 2013.
"""

from mex_binder import binder_py

mx_eyelink_broadcast_open = binder_py('mx_eyelink_broadcast_open')
mx_eyelink_broadcast_open.mx_c.headers = ['<eyelink.h>','"mex.h"']
mx_eyelink_broadcast_open.mx_c.code = '''

INT16 _main( void )
{
    return eyelink_broadcast_open(); 
}


void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
    double *status;
    mwSize td[2] = {1,1};
    
    /* Verify input arguments. */
    if(nrhs > 0 ) {
        mexErrMsgTxt("Incorrect number of inputs.");
    } else if( nlhs>1 ) {
        mexErrMsgTxt("Too many output arguments.");
    }
    
    plhs[0] = mxCreateNumericArray( 2, td, mxDOUBLE_CLASS, mxREAL);
    status  = mxGetPr(plhs[0]);    
    *status = (double ) _main();

    return;
    
}


'''

mx_eyelink_broadcast_open.mx_c.mdoc = \
'''function [ status ] = mx_eyelink_broadcast_open( )
%MX_EYELINK_BROADCAST_OPEN Allows a third computer to listen in on a session 
% between the eye tracker and a controlling remote machine. This allows it to
% receive data during recording and playback, and to monitor the eye tracker 
% mode. The local computer will not be able to send commands to the eye tracker, 
% but may be able to send messages or request the tracker time.
%
%Remarks:
%May not function properly, if there are more than one Ethernet cards installed.
%
% Returns:
% 0 if successful.
% -200 if link could not be established.
% -201 if tracker did not respond.
% -203 if the versions of the EyeLink library and tracker are incompatible.
%
'''
mx_eyelink_broadcast_open.write_c()
mx_eyelink_broadcast_open.write_m()
mx_eyelink_broadcast_open.compile()
mx_eyelink_broadcast_open.write_sh()

